package com.amigo.online.provider.adv.quartz.job;

import java.util.HashSet;
import java.util.Map;
import java.util.Set;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;

import com.amigo.online.provider.adv.util.AdvBasicUtil;

public abstract class AbstractSettleAdvStockJob {
    protected final Logger logger = LoggerFactory.getLogger(getClass());

    @SuppressWarnings("rawtypes")
    @Autowired
    protected RedisTemplate redisTemplate;

    @Autowired
    protected StringRedisTemplate stringRedisTemplate;

    protected static void complexRedisInitMap(String basicKey, Integer areaId, Integer sex, Integer age,
                                              Map<String, Set<String>> initListMap, Long id) {
        String redisKey = AdvBasicUtil.spliceAdvRedisKey(basicKey, areaId, sex, age);
        Set<String> tempSet = initListMap.get(redisKey);
        if (tempSet != null) {
            tempSet.add(String.valueOf(id));
        } else {
            tempSet = new HashSet<>();
            tempSet.add(String.valueOf(id));
            initListMap.put(redisKey, tempSet);
        }
    }
}
